<?php

ini_set('display_errors', true);

// Include application functions
// require_once(realpath(dirname(__FILE__) . '/../application/libraries/functions.php'));

// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
defined('LIBRARY_PATH') || define('LIBRARY_PATH', (getenv('LIBRARY_PATH') ? getenv('LIBRARY_PATH') : realpath(dirname(__FILE__) . '/../library')));	
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(
    LIBRARY_PATH 
    . PATH_SEPARATOR . 
    realpath(dirname(__FILE__) . '/../application/models') 
    . PATH_SEPARATOR .
	'../application/libraries/' . PATH_SEPARATOR
    . PATH_SEPARATOR .
    get_include_path()
);

// change session path in application
session_save_path(realpath(dirname(__FILE__) . '/../temp/sessions'));

require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);

/** Zend_Application */
require_once 'Zend/Application.php';

/** Functions */
require_once 'functions.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();
